<!DOCTYPE HTML>
<html lang="en">


<head><meta name="generator" content="Hexo 3.9.0">
    <meta charset="utf-8">
    <meta name="keywords" content="sql语言, 黄小华的个人网站">
    <meta name="description" content="





create database company
go

use companygo
if exists (select * from sysobjects where id = object_id(N’[dbo].[custom">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>sql语言 | 黄小华的个人网站</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">
    <style type="text/css">
        
    </style>

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
</head>


<body>

<header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">黄小华的个人网站</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fa fa-navicon"></i></a>
<ul class="right">
    
    <li class="hide-on-med-and-down">
        <a href="/" class="waves-effect waves-light">
            
            <i class="fa fa-home"></i>
            
            <span>Index</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/tags" class="waves-effect waves-light">
            
            <i class="fa fa-tags"></i>
            
            <span>Tags</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/categories" class="waves-effect waves-light">
            
            <i class="fa fa-bookmark"></i>
            
            <span>Categories</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/archives" class="waves-effect waves-light">
            
            <i class="fa fa-archive"></i>
            
            <span>Archives</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/about" class="waves-effect waves-light">
            
            <i class="fa fa-user-circle-o"></i>
            
            <span>About</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/friends" class="waves-effect waves-light">
            
            <i class="fa fa-address-book"></i>
            
            <span>Friends</span>
        </a>
    </li>
    
    <li>
        <a href="#searchModal" class="modal-trigger waves-effect waves-light">
            <i id="searchIcon" class="fa fa-search" title="Search"></i>
        </a>
    </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">黄小华的个人网站</div>
        <div class="logo-desc">
            
            在这里见证我的成长历程！
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li>
            <a href="/" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-home"></i>
                
                Index
            </a>
        </li>
        
        <li>
            <a href="/tags" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-tags"></i>
                
                Tags
            </a>
        </li>
        
        <li>
            <a href="/categories" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-bookmark"></i>
                
                Categories
            </a>
        </li>
        
        <li>
            <a href="/archives" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-archive"></i>
                
                Archives
            </a>
        </li>
        
        <li>
            <a href="/about" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-user-circle-o"></i>
                
                About
            </a>
        </li>
        
        <li>
            <a href="/friends" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-address-book"></i>
                
                Friends
            </a>
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/JxnuHxh/JxnuHxh.github.io" class="waves-effect waves-light" target="_blank">
                <i class="fa fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>

        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/JxnuHxh/JxnuHxh.github.io" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>





<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/1.jpg')">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        sql语言
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 20px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                          <div class="article-tag">
                            <span class="chip bg-color">No tag</span>
                          </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                <div class="post-date info-break-policy">
                    <i class="fa fa-calendar-minus-o fa-fw"></i>Publish Date:&nbsp;&nbsp;
                    2019-09-07
                </div>

                
				
				
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="fa fa-eye fa-fw"></i>Read Count:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <img src="/medias/table1.png">
<br>
<img src="/medias/table2.png">
<br>
<img src="/medias/table3.png">
<br>
create database company
go

<p>use company<br>go</p>
<p>if exists (select * from sysobjects where id = object_id(N’[dbo].[customer]’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)<br>drop table [dbo].[customer]<br>GO</p>
<p>if exists (select * from sysobjects where id = object_id(N’[dbo].[employee]’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)<br>drop table [dbo].[employee]<br>GO</p>
<p>if exists (select * from sysobjects where id = object_id(N’[dbo].[product]’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)<br>drop table [dbo].[product]<br>GO</p>
<p>if exists (select * from sysobjects where id = object_id(N’[dbo].[sale_item]’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)<br>drop table [dbo].[sale_item]<br>GO</p>
<p>if exists (select * from sysobjects where id = object_id(N’[dbo].[sales]’) and OBJECTPROPERTY(id, N’IsUserTable’) = 1)<br>drop table [dbo].[sales]<br>GO</p>
<p>/<em>员工人事表</em>/<br>CREATE TABLE employee(<br>emp_no char(5)not null primary key,<br>emp_name char(10) not null,<br>sex char(2) not null,<br>dept char(4) not null,<br>title char(6) not null,<br>date_hired datetime not null,<br>birthday datetime  null,<br>salary int not null,<br>telephone varchar(20) null,<br>addr char(50)  null,<br>)</p>
<p>/<em>客户表</em>/<br>create table  customer(<br>cust_id char(5) not null primary key,<br>cust_name char(20) not null,<br>addr char(40) not null,<br>tel_no char(20) not null,<br>zip char(6) null<br>)</p>
<p>/<em>销售主表</em>/<br>create table sales(<br>order_no int not null primary key,<br>cust_id char(5) not null,<br>sale_id char(5) not null,<br>tot_amt numeric(9,2) not null,<br>order_date datetime not null,<br>)</p>
<p>/<em>销货明细表</em>/<br>create table sale_item(<br>order_no int not null,<br>prod_id char(5) not null,<br>qty int not null,<br>unit_price numeric(7,2) not null,<br>order_date datetime null,<br>constraint pk_sale_item primary key<br>(order_no,prod_id )<br>)</p>
<p>/<em>产品名称表</em>/<br>create table product(<br>prod_id char(5) not null primary key,<br>prod_name char(20) not null<br>)</p>
<p>/<em>人事表（employee）数据：</em>/<br>insert employee values(‘E0001’,’王大华’,’男’,’业务’,’经理’,’1976-10-13’,’1951-08-01’,80000,’13107912134’,’上海市’)<br>insert employee values(‘E0003’,’陈自强’,’男’,’会计’,’科长’,’1986-09-15’,’1963-06-09’,48000,’13307913451’,’南京市’)<br>insert employee values(‘E0014’,’周小梅’,’女’,’业务’,’职员’,’1996-03-01’,’1970-03-28’,32000,’13579607879’,’上海市’)<br>insert employee values(‘E0009’,’陈建国’,’男’,’管理’,’科长’,’1987-04-15’,’1967-09-01’,45000,’13879787765’,’天津市’)<br>insert employee values(‘E0017’,’林光华’,’男’,’业务’,’职员’,’1995-10-13’,’1973-08-17’,30000,’13979765654’,’上海市’)<br>insert employee values(‘E0006’,’李珠珠’,’女’,’管理’,’经理’,’1988-01-01’,’1961-07-12’,60000,’13679787667’,’北京市’)<br>insert employee values(‘E0002’,’李庄敬’,’男’,’人事’,’科长’,’1980-09-15’,’1958-05-13’,80000,’13979962335’,’广州市’)<br>insert employee values(‘E0010’,’王成功’,’男’,’信息’,’职员’,’1993-02-15’,’1969-04-15’,45000,’13723456789’,’北京市’)<br>insert employee values(‘E0013’,’陈中华’,’男’,’业务’,’职员’,’1993-02-15’,’1966-07-01’,43000,’13978790987’,’天津市’)<br>insert employee values(‘E0008’,’刘  刚’,’男’,’业务’,’职员’,’1994-11-01’,’1968-08-01’,40000,’13767654543’,’上海市’)<br>insert employee values(‘E0005’,’李珊珊’,’女’,’会计’,’职员’,’1990-03-20’,’1967-04-25’,38000,’13890987876’,’上海市’)<br>insert employee values(‘E0011’,’李小蓉’,’女’,’人事’,’职员’,’1994-11-01’,’1970-11-18’,30000,’13345432321’,’重庆市’)<br>insert employee values(‘E0012’,’蔡文钦’,’男’,’制造’,’厂长’,’1984-08-15’,’1960-07-21’,50000,’13789876766’,’上海市’)<br>insert employee values(‘E0015’,’张大山’,’男’,’制造’,’职员’,’1993-12-15’,’1968-09-23’,35000,’13567657889’,’上海市’)<br>insert employee values(‘E0007’,’吴铁雄’,’男’,’信息’,’科长’,’1989-10-01’,’1965-04-18’,50000,’13389876765’,’武汉市’)<br>insert employee values(‘E0016’,’方美美’,’女’,’业务’,’职员’,’1992-05-20’,’1966-06-23’,40000,’13167688877’,’上海市’)<br>insert employee values(‘E0004’,’刘中兴’,’男’,’制造’,’经理’,’1984-05-01’,’1960-05-23’,60000,’13541586766’,’上海市’)<br>insert employee values(‘E0019’,’王仁华’,’男’,’信息’,’经理’,’1985-09-15’,’1959-03-24’,60000,’13122334545’,’上海市’)<br>insert employee values(‘E0020’,’陈火旺’,’男’,’业务’,’职员’,’1992-08-01’,’1964-05-12’,40000,’13978796622’,’天津市’)<br>insert employee values(‘E0018’,’林中正’,’男’,’管理’,’总经理’,’1974-10-01’,’1953-05-04’,100000,’13879765667’,’上海市’)</p>
<p>/*  客户（customer）表数据：*/<br>insert customer values(‘C0001’,’ABC股份有限公司’,’上海市’,’13879765667’,’500100’)<br>insert customer values(‘C0002’,’客户乙’,’天津市’,’13178788980’,’100300’)<br>insert customer values(‘C0003’,’客户丙’,’北京市’,’13345566789’,’100100’)<br>insert customer values(‘C0004’,’客户丁’,’上海市’,’13134455566’,’500210’)<br>insert customer values(‘C0005’,’客户戊’,’北京市’,’13677889890’,’100120’)<br>insert customer values(‘C0006’,’客户己’,’上海市’,’13767678899’,’500230’)<br>insert customer values(‘C0007’,’客户庚’,’上海市’,’13522334567’,’500300’)</p>
<p>/<em>销售（sales）主表数据:</em>/<br>insert sales values (10002,’C0002’,’E0013’,22700.00,’1996-11-10’)<br>insert sales values(10003,’C0003’,’E0014’,13960.00,’1996-10-15’)<br>insert sales values(10004,’C0003’,’E0014’,33000.00,’1996-11-18’)<br>insert sales values (10001,’C0001’,’E0008’,60000.00,’1996-11-10’)<br>insert sales values (10007,’C0008’,’E0008’,20000.00,’1996-11-22’)</p>
<p>/<em>销售明细表（sale_item）数据:</em>/<br>insert sale_item values (10001,’P0001’,5 , 2500.00,’1996-11-10’)<br>insert sale_item values (10001,’P0002’,3 , 6500.00,’1996-11-10’)<br>insert sale_item values (10001,’P0003’,2 , 5300.00,’1996-11-10’)<br>insert sale_item values (10002,’P0004’,2 , 1600.00,’1996-11-10’)<br>insert sale_item values (10002,’P0001’,3 , 2600.00,’1996-11-10’)<br>insert sale_item values (10002,’P0003’,1 , 5300.00,’1996-11-10’)<br>insert sale_item values (10003,’P0008’,2 , 4800.00,’1996-10-15’)<br>insert sale_item values (10003,’P0001’,4 , 2700.00,’1996-10-15’)<br>insert sale_item values (10004,’P0004’,2 , 1580.00,’1996-11-18’)<br>insert sale_item values (10004,’P0007’,4 , 2700.00,’1996-11-18’)<br>insert sale_item values (10007,’P0004’,2 , 1580.00,’1996-11-22’)</p>
<p>/<em>产品名称(product)表数据：</em>/<br>insert product values (‘P0001’,’16M DRAM’)<br>insert product values (‘P0002’,’14寸显示器’)<br>insert product values (‘P0003’,’1.2GB硬盘’)<br>insert product values (‘P0004’,’3.5寸软驱’)<br>insert product values (‘P0005’,’键盘’)<br>insert product values (‘P0006’,’VGA显示卡’)<br>insert product values (‘P0007’,’网卡’)<br>insert product values (‘P0008’,’Pentium100CPU’)<br>insert product values (‘P0009’,’激光打印机’)<br>insert product values (‘P0010’,’8倍速光驱’)<br>insert product values (‘P0011’,’计算机字典’)<br>insert product values(‘P0012’,’9600bits-s调制解调器’)<br>insert product values(‘P0013’,’Pentium主板’)</p>
<p>1、查询女职员所销售的订单号，订单金额。</p>
<p>select order_no.tot_amt<br>from sales left join employee<br>on sale_id=emp_no</p>
<p>2、查询在一张订单中订购了所有产品的订单号。</p>
<p>select order_no<br>from sale_item product<br>where prod_id=product.prod_id<br>and (select count(order_no) from sale_item)=(select count(*) from product)</p>
<p>3、查询每位顾客的总订购金额，并按总订购金额降序排列。</p>
<p>select cust_id,tit_amt<br>from sales<br>order by tott_amt desc</p>
<p>4、查询每种产品的订购数量总和，并显示出产品号、产品名及订单数量总和。</p>
<p>select a.prod_id,prod_name,sum(qty)Sum_product,count(order_no),Sum_order<br>from sale_item a,product b<br>where a.prod_id=b.prod_id<br>group by a.prod_id,prod_name</p>
<p>5、查询工资前五位职工的有关信息。</p>
<p>select top(5)*<br>from employee<br>order by salary desc</p>
<p>6、查询没有订购“P0004”产品的订单号。</p>
<p>select distinct order_no<br>from sale_item<br>where order_no not in(<br>select order_no<br>from sale_item<br>where prod_id=’P0004’<br>);</p>
<p>7、建一视图，该视图中包含业务部员工的员工号、员工名、订单号、客户名、订单金额。</p>
<p>create view v_employee<br>as<br>select emp_no,emp_name,order_no,custname,tot_amt<br>from employee,sales,customer<br>where sale_id=order_no and sales.cust_id=customer.cust_id;</p>
<p>8、对员工表添加一核查约束，限定员工性别只能取“男”或“女”。</p>
<p>alter table employee<br>add constraint C1 check(sex in(‘男’,’女’))</p>
<p>9、建一存储过程，当删除给定编号的员工时，实现级联删除，即既要删除员工表中的记录，又要删除销售主表及销售明细表的记录。</p>
<p>create  procedure cascading_deletion<br>@Number char(5),<br>@begin char(5)=’false’<br>as<br>begin </p>
<pre><code>if (@begin=&apos;true&apos;)
  begin
     alter table sales add constraint name1 foreign key (sale_id) references  employee(emp_no) ON DELETE CASCADE
     alter table sale_item add constraint name2 foreign key (order_no) references sales (order_no) ON DELETE CASCADE  
  end
delete from employee where emp_no=@Number;</code></pre><p>end</p>
<p>10、现有数据库中sales销售主表中的订单金额并不正确，它不是某订单中所有订单明细的商品数量*单价的总和。请创建一个存储过程，修改sales表中的订单金额tot_amt，使之等于各订单对应的所有订单明细的数量与单价的总和。</p>
<p>CREATE PROCEDURE S10 AS BEGIN<br>    UPDATE sales<br>SET tot_amt = ( SELECT SUM ( qty * unit_price ) FROM sale_item WHERE sales.order_no= sale_item.order_no GROUP BY order_no )<br>END</p>
<p>11、创建一个触发器，当对sale_item表进行插入、删除或修改商品数量qty及商品单价unit_price时，及时更新sales表中的订单金额tot_amt。</p>
<p>CREATE TRIGGER update_totAmt ON sale_item after INSERT,<br>DELETE,<br>UPDATE AS BEGIN<br>        UPDATE sales<br>        SET tot_amt = ( SELECT SUM ( unit_price * qty ) FROM sale_item WHERE order_no = sales.order_no )<br>    END</p>

            </div>
            <hr/>

            
            <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.88rem;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-large waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fa fa-close"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            

            <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    <div class="social-share" data-disabled="qzone, qq, weibo, douban"></div>
    
</div>

<script src="/libs/share/js/social-share.min.js"></script>

            

    <div class="reprint" id="reprint-statement">
        <p class="reprint-tip">
            <i class="fa fa-exclamation-triangle"></i>&nbsp;&nbsp;
            <span>Reprint policy</span>
        </p>
        
            <div class="center-align">
                <a rel="license" href="https://creativecommons.org/licenses/by/4.0/">
                    <img alt=""
                         style="border-width:0"
                         src="https://i.creativecommons.org/l/by/4.0/88x31.png"/>
                </a>
            </div>
            <br/>
            <span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text"
                  property="dct:title" rel="dct:type">
                    《sql语言》
                </span> by
            <a xmlns:cc="http://creativecommons.org/ns#" href="/2019/09/07/sql语言/" property="cc:attributionName"
               rel="cc:attributionURL">
                黄小华
            </a> is licensed under a
            <a rel="license" href="https://creativecommons.org/licenses/by/4.0/">
                Creative Commons Attribution 4.0 International License
            </a> 
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>Copied successfully, please follow the reprint policy of this article</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">more</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>


        </div>
    </div>

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fa fa-chevron-left"></i>&nbsp;Previous</div>
            <div class="card">
                <a href="/2019/09/12/数据库/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/21.jpg" class="responsive-img" alt="数据库">
                        
                        <span class="card-title">数据库</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            数据库: 数据的仓库 永久存放  ， 方便解析/管理  服务
 主流关系型数据库：   Oracle：产品免费，服务收费，强大稳定性，安全性   mysql: AB开源 企业版收费，产品免费，服务收费   sql server: 微软开发 
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="fa fa-clock-o fa-fw icon-date"></i>2019-09-12
                        </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-user fa-fw"></i>
                            黄小华
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                Next&nbsp;<i class="fa fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2019/09/07/算法排序/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/3.jpg" class="responsive-img" alt="算法排序">
                        
                        <span class="card-title">算法排序</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            稳定：如果a原本在b前面，而a=b，排序之后a仍然在b的前面；不稳定：如果a原本在b的前面，而a=b，排序之后a可能会出现在b的后面；内排序：所有排序操作都在内存中完成；外排序：由于数据太大，因此把数据放在磁盘中，而排序通过磁盘和内存的数据
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="fa fa-clock-o fa-fw icon-date"></i>2019-09-07
                            </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-user fa-fw"></i>
                            黄小华
                            
                        </span>
                    </div>
                </div>
                
            </div>
        </div>
        
    </div>
</article>
</div>



    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="fa fa-list-alt"></i>&nbsp;&nbsp;TOC</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fa fa-list"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            // headingsOffset: -205,
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).slideUp(500);
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).slideDown(500);
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>
    

</main>


<footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            本站由&copy;<a href="https://blinkfox.github.io/" target="_blank">Blinkfox</a>基于
            <a href="https://hexo.io/" target="_blank">Hexo</a> 的
            <a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">hexo-theme-matery</a>主题搭建.

            

            
			
                <br>
                
                <span id="busuanzi_container_site_pv">
                    <i class="fa fa-heart-o"></i>
                    本站总访问量 <span id="busuanzi_value_site_pv" class="white-color"></span>
                </span>
                
                
                <span id="busuanzi_container_site_uv">
                    <i class="fa fa-users"></i>
                    次,&nbsp;访客数 <span id="busuanzi_value_site_uv" class="white-color"></span> 人.
                </span>
                
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fa fa-github"></i>
    </a>



    <a href="mailto:617662163@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fa fa-envelope-open"></i>
    </a>



    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=617662163" class="tooltipped" data-tooltip="QQ联系我: 617662163" data-position="top" data-delay="50">
        <i class="fa fa-qq"></i>
    </a>


</div>
    </div>
</footer>

<div class="progress-bar"></div>


<!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fa fa-search"></i>&nbsp;&nbsp;Search</span>
            <input type="search" id="searchInput" name="s" placeholder="Please enter a search keyword"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
<!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fa fa-angle-up"></i>
    </a>
</div>


<script src="/libs/materialize/materialize.min.js"></script>
<script src="/libs/masonry/masonry.pkgd.min.js"></script>
<script src="/libs/aos/aos.js"></script>
<script src="/libs/scrollprogress/scrollProgress.min.js"></script>
<script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
<script src="/js/matery.js"></script>

<!-- Global site tag (gtag.js) - Google Analytics -->




    <script async src="/libs/others/busuanzi.pure.mini.js"></script>


</body>
</html>